/**
 * cavion（曹仁道）
 * caorendao187@163.com
 * 2017年6月12日 下午10:39:30
 */
package org.rk.core.common.http;

import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.HttpClientBuilder;

/**
 * @author cavion
 * @类描述：
 * 2017年6月12日
 */
public class SSLClient extends HttpClientBuilder {
	public SSLClient() throws Exception{  
        super();  
        SSLContext ctx = SSLContext.getInstance("TLS");  
        X509TrustManager tm = new X509TrustManager() {  
                @Override  
                public void checkClientTrusted(X509Certificate[] chain,  String authType) throws CertificateException {  
                }  
                @Override  
                public void checkServerTrusted(X509Certificate[] chain,  String authType) throws CertificateException {  
                }  
                @Override  
                public X509Certificate[] getAcceptedIssuers() {  
                    return null;  
                }  
        };  
        ctx.init(null, new TrustManager[]{tm}, null);  
        SSLConnectionSocketFactory ssf = new SSLConnectionSocketFactory(ctx);  
        //HttpClientConnectionManager hccm = this.ge;  
        //SchemeRegistry sr = hccm.getSchemeRegistry();  
        //sr.register(new Scheme("https", 443, ssf));  
    }  
}
